#include "rule.h"
#include "table.h"

#include <string>

#include "or_rule.h"
#include "regex_rule.h"
#include "seq_rule.h"

using namespace std;
using namespace fouine;

Likelihood Rule::match(const String& s, int start, int length, const Table& table) const
{
  return _rule_impl->match(s, start, length, table);
}

Rule::Rule(const Rule& other)
:_rule_impl(other._rule_impl)
{}

Rule Rule::makeOrRule(const std::vector<RuleId>& rule_ids_)
{  return Rule(RulePtr(new OrRule(rule_ids_)));  }

Rule Rule::makeRegexRule(const String& ptn_)
{  return Rule(RulePtr(new RegexRule(ptn_)));    }

Rule Rule::makeSeqRule(const std::vector<RuleId>& rule_ids_)
{  return Rule(RulePtr(new SeqRule(rule_ids_))); };

Likelihood Rule::test_match(const String& s) const
{
  return _rule_impl->test_match(s);
}

Rule::Rule(boost::shared_ptr<RuleImpl> impl)
:_rule_impl(impl)
{}

RuleImpl::~RuleImpl() {}
